﻿@using System.Diagnostics.CodeAnalysis
@using System.Globalization;

@inherits InputBase<TimeSpan>

<input type="time" class="@CssClass"
       @attributes="AdditionalAttributes" value="@BindConverter.FormatValue(CurrentValueAsString)" onchange="@((ChangeEventArgs __e) => CurrentValueAsString = Convert.ToString(__e.Value))" />
@code {
   
    protected override bool TryParseValueFromString(string? value,
        [MaybeNullWhen(false)] out TimeSpan result,
        [NotNullWhen(false)] out string validationErrorMessage)
    {
        validationErrorMessage = "";
        if (value != null)
        {
            result = TimeSpan.Parse(value);
        }
        else
        {
            result = TimeSpan.Zero;
        }
        return true;
    }
}